package com.noahplat.person.pojo;


import lombok.Data;
import org.hibernate.validator.constraints.Length;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

/**
 * 功能：人员病史实体类
 * name:宋彦磊
 * time:2021.02.28
 */

@Data
@Table(name = "tb_ehrs")
public class Ehrs implements Serializable {
    @Id
    @KeySql(useGeneratedKeys = true)
    private Long id;   //主键ID
    private Long pid;  //人员ID

    @NotNull(message = "当前用药不能为空")
    @Length(max = 255)
    @Column(name = "cur_drug")
    private String cdrug; //当前用药

    @NotNull(message = "过敏反应不能为空")
    @Length(max = 255)
    private String anaphylaxis; //过敏反应

    @NotNull(message = "既往病史不能为空")
    @Length(max = 512)
    private String anamnesis;  //既往病史

    @NotNull(message = "家族病史不能为空")
    @Length(max = 512)
    @Column(name = "family_history")
    private String fhistory;  //家族病史

    @Transient
    private List<MedicalRecord> medicalRecords; //表外字段，用于封装就诊记录

    /**
     * 无参构造
     */
    public Ehrs() {
    }

    /**
     * 重写有参构造
     * @param pid
     * @param cdrug
     * @param anaphylaxis
     * @param anamnesis
     * @param fhistory
     */
    public Ehrs(Long pid, @NotNull(message = "参数不能为null") @Length(max = 255) String cdrug, @NotNull(message = "参数不能为null") @Length(max = 255) String anaphylaxis, @NotNull(message = "参数不能为null") @Length(max = 512) String anamnesis, @NotNull(message = "参数不能为null") @Length(max = 512) String fhistory) {
        this.pid = pid;
        this.cdrug = cdrug;
        this.anaphylaxis = anaphylaxis;
        this.anamnesis = anamnesis;
        this.fhistory = fhistory;
    }
}
